package com.ruoyi.web.controller.common.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ErpSending;
import com.ruoyi.system.service.IErpSendingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 寄件申请Controller
 * 
 * @author ruoyi
 * @date 2025-03-26
 */
@RestController
@RequestMapping("/system/sending")
public class ErpSendingController extends BaseController
{
    @Autowired
    private IErpSendingService erpSendingService;

    /**
     * 查询寄件申请列表
     */
//    @PreAuthorize("@ss.hasPermi('system:sending:list')")
    @GetMapping("/list")
    public TableDataInfo list(ErpSending erpSending)
    {
        startPage();
        List<ErpSending> list = erpSendingService.selectErpSendingList(erpSending);
        return getDataTable(list);
    }

    /**
     * 导出寄件申请列表
     */
//    @PreAuthorize("@ss.hasPermi('system:sending:export')")
    @Log(title = "寄件申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ErpSending erpSending)
    {
        List<ErpSending> list = erpSendingService.selectErpSendingList(erpSending);
        ExcelUtil<ErpSending> util = new ExcelUtil<ErpSending>(ErpSending.class);
        util.exportExcel(response, list, "寄件申请数据");
    }

    /**
     * 获取寄件申请详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:sending:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(erpSendingService.selectErpSendingById(id));
    }

    /**
     * 新增寄件申请
     */
//    @PreAuthorize("@ss.hasPermi('system:sending:add')")
    @Log(title = "寄件申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ErpSending erpSending)
    {
        return toAjax(erpSendingService.insertErpSending(erpSending));
    }

    /**
     * 修改寄件申请
     */
//    @PreAuthorize("@ss.hasPermi('system:sending:edit')")
    @Log(title = "寄件申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ErpSending erpSending)
    {
        return toAjax(erpSendingService.updateErpSending(erpSending));
    }

    /**
     * 删除寄件申请
     */
//    @PreAuthorize("@ss.hasPermi('system:sending:remove')")
    @Log(title = "寄件申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(erpSendingService.deleteErpSendingByIds(ids));
    }
}
